
const { contextBridge, ipcRenderer } = require("electron");
const openWebsite = (url) => {
    ipcRenderer.invoke("on-openWebsite-event", url);
};
const sendURL = async (url) => {
    const result = await ipcRenderer.invoke("on-url-event", url);
    return result;
};
const alert = (msg) => {
    ipcRenderer.invoke("on-alert-event", msg);
};
const getFileList = async () => {
    const fileList = await ipcRenderer.invoke("on-getFileList-event");
    return fileList;
};
const openDialog = () => {
    ipcRenderer.send("on-openDialog-event")
};
const onRendererEvent = (callback) => {
    return new Promise((resolve, reject) => {
        ipcRenderer.on("on-renderer-event", (e, type) => {
            // type ? resolve(type) : reject("数据混乱，不知道给你返回啥啦");
            callback();
            type ? resolve(type) : reject("数据混乱，不知道给你返回啥啦");
        });
    })
}
contextBridge.exposeInMainWorld("CONTEXTAPI", {
    onRendererEvent,
    openDialog,
    getFileList,
    openWebsite,
    sendURL,
    alert
})